package com.personal.service.impl;

import com.personal.dao.EnterpriseDao;
import com.personal.domain.Enterprise;
import com.personal.service.EnterpriseService;
import com.personal.util.partDisplay.EnterprisePart;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class EnterpriseServiceImpl implements EnterpriseService {



    @Autowired
    private EnterpriseDao enterpriseDao;
    @Override
    public List<Enterprise> selectAll() {
        return enterpriseDao.selectAll();
    }

    @Override
    public List<EnterprisePart> selectPartAll(){
        List<EnterprisePart> list=enterpriseDao.selectPartAll();
        return list;
    }

    @Override
    public List<EnterprisePart> selectPartByKey(String customerName, String customerCode) {
        List<EnterprisePart> list=enterpriseDao.selectPartByKey(customerName,customerCode);
        return list;
    }



    @Override
    public boolean add(Enterprise enterprise) {
        int flag=enterpriseDao.add(enterprise);
        if(flag>0)
            return true;
        return false;

    }

    @Override
    public Enterprise getUpdateData(int id) {
        return enterpriseDao.getUpdateData(id);
    }

    @Override
    public boolean update(Enterprise enterprise) {
        int flag=enterpriseDao.update(enterprise);
        if(flag>0)
            return true;
        return false;

    }

    @Override
    public boolean delete(List<Integer> ids) {

        for(Integer id:ids){
            int flag=enterpriseDao.delete(id);
            if(flag<0)
                return false;
        }
        return true;

    }

}
